<#import "/macro.ftl" as m>
<@m.page_header title='APP启动画面' />
<div id="page-content-wrapper">
    <div id="page-title">
        <h3>APP启动画面</h3>
        <div id="breadcrumb-right">
            <div class="float-right">
                <a href="/splashscreenschedules/add" class="btn medium primary-bg">
                    <span class="button-content">添加APP启动画面</span>
                </a>
            </div>
        </div>
    </div>
    <div id="page-content">
    	<form id="form" action="/splashscreenschedules" method="get">
    		<div class="form-row">
    			<div class="form-input col-md-6">
    				<input placeholder="填写描述查询" type="text" name="description" id="description" value="${description}">
    			</div>
    			<div class="form-input col-md-2">
		        	<a href="javascript:;" class="btn large primary-bg radius-all-4" id="search" title="Validate!" onclick="$('#form').trigger('submit');">
			            <span class="button-content">查询</span>
	                </a>
		        </div>
    		</div>
    		<div class="form-row">
    			<div class="form-input col-md-4">
    				<input type="hidden" id="isShow" name="isShow" value="${isShow?string('true', 'false')}">
                    <a href="#" class="btn medium <#if isShow > bg-blue <#else> font-blue </#if>" onclick="searchIsShow(true);">
                    	<span class="button-content">正显示启动画面</span>
                    </a>
                    <a href="#" class="btn medium <#if isShow > font-blue <#else> bg-blue </#if>" onclick="searchIsShow(false);">
                    	<span class="button-content">已过期启动画面</span>
                    </a>
                </div>
    		</div>
    	</form>
    	<table id="splashscreenschedules" class="table">
	        <thead>
	            <tr>
	            	<th>描述</th>
	            	<th>设备</th>
	                <th>开始时间</th>
	                <th>结束时间</th>
	                <th>显示优先级</th>
	                <th>操作</th>
	            </tr>
	        </thead>
	        <tbody>
	        	<#list schedules.list as schedule>
					<tr id="${schedule.id}">
					 	<td>${schedule.description}</td>
					 	<td>${schedule.device}</td>
		                <td>${schedule.startTime?string('yyyy-MM-dd HH:mm:ss')}</td>
		                <td>${schedule.endTime?string('yyyy-MM-dd HH:mm:ss')}</td>
		                <td>${schedule.priority}</td>
		                <td>
		                    <a href="/splashscreenschedules/${schedule.id}/edit" class="btn medium primary-bg">
		                    	<span class="button-content">编辑</span>
		                    </a>
		                    <a href="javascript:;" class="btn medium primary-bg" onclick="showDeleteSplashScreenSchedule(${schedule.id});">
		                    	<span class="button-content">删除</span>
		                    </a>
		                </td>
		            </tr>
				</#list>    
	    	</tbody>
	    </table>
	    <div class="button-group center-div">
	    	${pagerHelper.content}
	    </div>
    </div>
</div>

<script>

// 查询
function searchIsShow( isShow ) {
	$('#isShow').val(isShow);
	$('#form').trigger('submit');
}

function showDeleteSplashScreenSchedule( id ){
	$.messager.confirm( "提示", "启动画面排期吗？", function(){
		$.ajax({
		    url: '/splashscreenschedules/' + id,
		    type: 'POST',
		    data: { _method: 'DELETE' }
		})
	    .done(function(data){
	     	if(data["status"] == "success"){
	     		$.jGrowl("删除启动画面排期成功", {sticky:!1,position:"top-right",theme:"bg-green"});
	     		$('.table').find('tr[id=' + id + ']').remove();
	     	}else{
	     		$.jGrowl(data["message"], {sticky:!1,position:"top-right",theme:"bg-red"});
	     	}
	     })
	     .fail(function(){
	     	$.jGrowl("删除启动画面排期失败", {sticky:!1,position:"top-right",theme:"bg-red"});
	     });
	});
};

</script>